package com.heima.wemedia.controller.v1;


import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.impl.WmChannelServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 查询所有频道
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    /**
     * 删除频道
     * @param channelId
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable("id") Integer channelId){
        return wmChannelService.delChannel(channelId);
    }

    /**
     * 保存频道
     * @param adChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody AdChannel adChannel){
       return wmChannelService.saveChannel(adChannel);
    }

    /**
     * 管理端对频道分类查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody ChannelDto dto){
        return wmChannelService.findList(dto);
    }

    /**
     * 修改频道
     * @param adChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody AdChannel adChannel){
        return wmChannelService.updateChannel(adChannel);
    }
}
